package org.lex.ftplist.core;

import java.util.Arrays;

public class FtpUrl {
	public String user = "anonymous";
	public char[] password = "anonymous@anonymous.org".toCharArray();
	public String host = "localhost";
	public int port = 21;
	public String path = "/";

	public String toString() {
		return "ftp://" + user + ":" + new String(password) + "@" + host + ":" + port + path;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((host == null) ? 0 : host.hashCode());
		result = prime * result + Arrays.hashCode(password);
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		result = prime * result + port;
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FtpUrl other = (FtpUrl) obj;
		if (host == null) {
			if (other.host != null)
				return false;
		} else if (!host.equals(other.host))
			return false;
		if (!Arrays.equals(password, other.password))
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		if (port != other.port)
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}
}
